package com.lagou.bigdata.task02;


import java.io.File;
import java.util.Scanner;

/*
* 实现将指定目录中的所有内容删除，包含子目录中的内容都要全部删除
* */
public class DeleteFile {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要删除的目录：");

        String path = sc.next();
        directoryDelete(path);
    }

    public static void directoryDelete(String path){
        File file = new File(path);

        if (file.isDirectory()) {
            File[] files = file.listFiles();
            assert files != null;
            for (File tf : files) {
                directoryDelete(tf.getAbsolutePath());
            }
        }

        file.delete();
    }

}
